package com.zhuangwei.spring.controller;

import com.zhuangwei.spring.server.PrintServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;

/**
 * @author 文希
 * @create 2019-05-24 16:48
 **/
@RestController
public class HelloController {
    @Autowired
    private PrintServer printServer;

    @ResponseBody
    @GetMapping("hello")
    public String sayHello(HttpServletRequest request) throws UnsupportedEncodingException {
        printServer.print();
        String name = new String(request.getParameter("name").getBytes("iso-8859-1"), "utf-8");
        return "hello, " + name;
    }
}
